import React from 'react';
import { message } from 'antd';
import { acceptRecruitmentByEncryptId } from '@/services/user';

export default ({ form, setStatus, employId }) => {
    const [submitLoading, setSubmitLoading] = React.useState(false);
    const optionList = [
        { label: '已收到其他offer', value: 4 },
        { label: '工作内容不契合', value: 5 },
        { label: '离家太远', value: 6 },
        { label: '其他', value: 99 }
    ];
    const handleSubmit = () => {
        form.validateFields(async (err, values) => {
            if (!err) {
                console.log(values);
                setSubmitLoading(true);
                // 拒绝录用：employState 8
                const res = await acceptRecruitmentByEncryptId({ ...values, employId, employState: 8 });
                setSubmitLoading(false);
                if (res.code === 10000) {
                    setStatus('reject');
                } else {
                    message.error(res.msg);
                }
            }
        });
    };
    return { submitLoading, handleSubmit, optionList };
};
